#define _WIN32_WINNT  0x501
//
//  Client.h
//  Projet A2014
//
//  Created by Jules Thuillier on 03/11/2014.
//  Copyright (c) 2014 Jules Thuillier Erwan Marchand. All rights reserved.
//
// link with Ws2_32.lib 
#pragma comment(lib, "ws2_32.lib")

#ifndef __Projet_A2014__Client__
#define __Projet_A2014__Client__

#include <stdio.h>
#include <string>
#include <winsock2.h>
#include <iostream>
#include <algorithm>
#include <strstream>
#include <vector>
#include <ws2tcpip.h> 

class Client {

public:

	Client();
	~Client();

	void receive();
	int NbrCandidats(char* motRecu);

    
private:
	//int  sendMessage(string& message);
    bool initLibWinsock();
    bool initSocket();
    bool scannerAdresses();
    bool connectionAuServeur();

	//check receive
	void ajouterMot(char* motRecu);
	bool ReceptionFinie();
	void traiterDonneesRecu();
	std::string choisirRandom();
    
    void fermerSocket();
    
    // Informations sur le client
    char* clientIP;

    char* Port;
    
    // Informations sur le serveur
    char* serveurIP;
  
    WSADATA wsaData;
    SOCKET leSocket;
    struct addrinfo *result = NULL,
                    *ptr = NULL,
                    hints;

	sockaddr_in *adresse;

	std::string TexteRecu;
	std::vector<std::string> listeCandidats;
	int nombreCandidats;
	bool TraitementFait;
    
};

#endif /* defined(__Projet_A2014__Client__) */
